package com.yxplearn.mybatisplus.pojo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.yxplearn.mybatisplus.manager.CompositePersistEntity;

/**
 * @author gcx
 */
public class Users extends CompositePersistEntity<User> {

    private long playerId;
    // key: templateId value: Achievement
    private Map<Long, User> users = new ConcurrentHashMap<>();

    public Users() {
    }

    public Users(long playerId, List<User> list) {
        this.playerId = playerId;
        for (User a : list) {
            users.put(a.getId(), a);
        }
    }
    
    public Map<Long, User> getUsers() {
		return users;
	}

	public void setUsers(Map<Long, User> users) {
		this.users = users;
	}

	@Override
    public long getPlayerId() {
        return playerId;
    }

    public void setPlayerId(int playerId) {
        this.playerId = playerId;
    }

    @Override
    protected CompositePersistEntity<User> cloneEntity() {
        Users clone = null;
        try {
            clone = (Users) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return clone;
    }

    @Override
    protected List<User> parameterPersistEntities() {
        return new ArrayList<>(users.values());
    }

}
